home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.inap.net!news1!ind-004-236-188
- From: dlmiller@iquest.net (Doug Miller)
- Subject: Re: help with strcmp
- X-Nntp-Posting-Host: ind-004-236-188.iquest.net
- Message-ID: <DpAI6o.2Cq@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Network Services
- X-Newsreader: News Xpress Version 1.0 Beta #2.1
- References: <4jpiek$lp6@blaze.cs.jhu.edu>
- Date: Wed, 3 Apr 1996 14:15:58 GMT
-
- I don't notice any place where you have allocated storage for fp prior to attempting to transfer
- data to it.
-
- lasher@hops.cs.jhu.edu (John E. Davis) wrote:
- >For some reason when I try to compare the strings in the following
- >snippet I consistently get a core dump (running on a UNIX machine running
- >Solaris). Could anyone point out what may be going wrong? I have run it
- >through the debugger and that was no help at all for me. here is the
- >code snippet:
- >
- >#include <stdio.h>
- >#include <stdlib.h>
- >#include <string.h>
- >
- >void setup(FILE *);
- >
- >void main(int argc, char *argv[])
- >{
- >char buf[20], data[40], *buff, *arg, *fp;
- >FILE *handle, *dest;
- >int n;
- >
- >handle = fopen(argv[1], "r");
- >if(dest = fopen( "dbuild.out", "w")) setup(dest);
- >
- >while(!feof(handle)) {
- > n = 0;
- > fp = fgets(data, 40, handle);
- > if ( strcasecmp(fp, "<action>\n") == 0) /* the coredump is here */
- > parseAction(handle, dest);
- > else if ( strcasecmp(fp, "<control>\n") == 0)
- > parseControl(handle, dest);
- > else if ( strcasecmp(fp, "<general>\n") == 0)
- > parseGeneral(handle, dest);
- > printf("%s", data);
- > }
- >fclose(dest);
- >
- >}
- >
- >
- >--
- >John Davis
- >lasher@hops.cs.jhu.edu
- >http://hops.cs.jhu.edu/~lasher
- >
- >UNIX is a very user-friendly operating system
- > it's just picky about who it's friends with.
-
-